package top.chukongxiang.dubboboot.simple.gateway.controller.user;

import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.chukongxiang.dubboboot.simple.common.model.response.R;
import top.chukongxiang.dubboboot.simple.common.service.UserService;
import top.chukongxiang.dubboboot.simple.common.model.entity.user.User;

/**
 * 用户基础相关
 * @author 楚孔响
 * @version 1.0
 * @date 2021/12/11 4:02
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @DubboReference
    UserService userService;

    /**
     * 根据用户名获取用户信息
     * @param username 用户名
     * @return 响应
     */
    @GetMapping("{username}")
    public R<User> getInfoById(@PathVariable String username) {
        return R.ok(userService.getUserInfoByUsername(username));
    }

}
